﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;

namespace Common.Core.Configuration
{
	public class NameTypeContainerElement<NamedElementType> : ConfigurationElement where NamedElementType : NamedConfigurationElement, new()
	{
		protected override bool OnDeserializeUnrecognizedElement(string elementName, System.Xml.XmlReader reader)
		{
			NamedElementType element = new NamedElementType();
			element.Name = elementName;
			element.DeserializeElement( reader );

			ConfigurationProperty property = new ConfigurationProperty( elementName, typeof(NamedElementType) );
			Properties.Add( property );
			this[elementName] = element;
			return true;
		}
	}
}
